Many applications and libraries are distributed in an intermediate format, such as the MICROSOFT® Intermediate Language (MSIL). These intermediate language binaries (also known as managed assemblies in the case of MICROSOFT® .NET) are typically compiled dynamically at runtime in a virtual machine environment using a Just-in-Time (JIT) compiler. An alternative to dynamic compilation is pre-compilation via Native Generation (NGen). NGen generates machine code and runtime data structures from the intermediate language and persists them in files on disk. The images produced by NGen are called Native or NGen images. Unlike JIT-compiled code, code and data structures in NGen images can be shared across processes. For libraries and frameworks that are typically shared across multiple processes, NGen is extremely useful since it minimizes the working set of each managed process. NGen therefore reduces the overall memory utilization of the system. NGen is also very useful for minimizing start up time of client-side applications.
Several managed platforms/applications are using NGen. Unfortunately, however, it is quite difficult to use NGen in these current platforms. One difficulty that NGen introduces is with servicing. NGen images are persisted on disk, and have to be regenerated as the corresponding intermediate language binaries get updated. Pre-compilation via NGen introduces a servicing burden, which is made worse by the fact that NGen images are “servicing-unfriendly”. One of the biggest issues with servicing NGen images is the fact that servicing an intermediate language binary not only requires the corresponding NGen image to be regenerated, but also requires all intermediate language binaries that depended on the serviced binary to be recompiled. Therefore servicing a binary that a large number of intermediate language binaries depend upon, on a machine that has a lot of managed applications and NGen images, can result in long servicing events or long periods of background compilation which consume machine resources and adversely impact managed application performance.